package com.sl.au.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.sl.au.entity.Account;
import com.sl.au.entity.EXDEpayHistoryInfo;
import com.sl.au.service.EXDEpayHistoryService;
import com.sl.utils.ExdeUtil;

/**
 * 合同回款历史控制器
 * zty
 * 2017-02-20
 */
@RestController
@RequestMapping(value="/ui/payHistory")
public class PayHistoryController extends BaseController{
	@Autowired
	EXDEpayHistoryService exdepayhistoryservice;
	@RequestMapping(method = RequestMethod.GET)
    public ModelAndView index(){
        ModelAndView modelAndView=createLayoutView("paymentSearch/payHistory");
        return modelAndView;
    }
    @RequestMapping(value = "/getpage", method = RequestMethod.GET)
	public Map<String, Object> getpage(HttpServletRequest request) {
		Map<String,Object> map = new HashMap<String,Object>();
		Account a = this.getMyAccount();
		int start = Integer.parseInt(request.getParameter("start"));
		int length = Integer.parseInt(request.getParameter("length"));
		String superior = a.getUser().getSaleArea().getSuperior(); //获取部门信息
		//String superior = "销售处";
		String key = request.getParameter("key");
        List<EXDEpayHistoryInfo> users = null;
		users = exdepayhistoryservice.getMyPage(start,length,superior,key);
		long count =0;		
		count=exdepayhistoryservice.getCount(length, length, superior,key);
		System.out.println(count);
		map.put("data", users);
		map.put("draw", request.getParameter("draw"));
		map.put("recordsFiltered", count);
		map.put("recordsTotal", count);
		return map;
	}
    
}
